﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Enumerations;
using AspNetCs.Enumerations.User_Enum;
using AspNetCs.Bll;
using AspNetCs.Model;

public partial class Users_MyInfo : BasePage
{
    protected Users UserBll = new Users();

    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserExit("Login.Aspx?ReUrl=" + configInfo.InstallDir + "Users/MyInfo.Aspx", "", true);
        if (!Page.IsPostBack)
        {

            this.Radio_Sex.DataTextField = "EnumDisplayText";
            this.Radio_Sex.DataValueField = "EnumDisplayText";
            this.Radio_Sex.DataSource = EnumDescription.GetFieldTexts(typeof(Sex_Enum), EnumDescription.SortType.Rank);
            this.Radio_Sex.DataBind();
            Radio_Sex.RepeatColumns = 5;
            if (Base_GetUserInfo.Sex != "")
            {
                this.Radio_Sex.Items.FindByValue(Base_GetUserInfo.Sex).Selected = true;
            }
            else
            {
                this.Radio_Sex.SelectedIndex = 0;
            }


            this.StrQ1.DataTextField = "EnumDisplayText";
            this.StrQ1.DataValueField = "EnumValueStr";
            this.StrQ1.DataSource = EnumDescription.GetFieldTexts(typeof(Question_Enum), EnumDescription.SortType.Rank);
            this.StrQ1.DataBind();
                ListItem Itm = new ListItem("请选择密码提示问题？", "");
            if (Base_GetUserInfo.Quesion != "")
            {
                this.StrQ1.Items.FindByValue(Base_GetUserInfo.Quesion).Selected = true;
            }
            else
            {

                Itm.Selected = true;
            }
                this.StrQ1.Items.Add(Itm);
                this.Txt_Ans.Text = Base_GetUserInfo.Answer;
                this.Txt_Mail.Text = Base_GetUserInfo.UserEmail;
                this.Txt_Brith.Text = Base_GetUserInfo.Birthday;
                this.Txt_Moblie.Text = Base_GetUserInfo.UserMobile;
                this.Txt_HomePage.Text = Base_GetUserInfo.HomePage;
                this.Txt_QQ.Text = Base_GetUserInfo.QQ;
                this.Txt_Msn.Text = Base_GetUserInfo.Msn;



        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string Question = StrQ1.SelectedValue;
        string Ans = Txt_Ans.Text;
        string Emlstr = Txt_Mail.Text;
        string birth = Txt_Brith.Text;
        string Tel = Txt_Moblie.Text;
        string HomePage = Txt_HomePage.Text;
        string QQ = Txt_QQ.Text;
        string Msn = Txt_Msn.Text;
        Users_Model md=new Users_Model();
            
        md.UserId = Base_GetLoginInfo.GetUserID;
        md.Quesion = Question;
        md.Answer = Ans;
        md.UserEmail = Emlstr;
        md.Birthday = birth;
        md.UserMobile = Tel;
        md.HomePage = HomePage;
        md.QQ = QQ;
        md.Msn = Msn;
        md.Sex = Radio_Sex.SelectedValue;
      UserBll.update(md);
      Response.Redirect("MyInfo.Aspx");
      Response.End();
    }
}
